if product open display this button

55

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30, 0);
add_action( 'woocommerce_single_product_summary', 'custom_button_by_categories', 32 ,0 );
function custom_button_by_categories(){
    
    global $product;

    // Define your categories in this array (can be Ids, slugs or names)
    $product_cats = array('clothing', 'music', 'furnitures');

    if( has_term( $product_cats, 'product_cat', $product->get_id() ) ){
         $demo_url = get_post_meta( $product->get_id(), 'demo_url', true );
         echo '<a class="fancybox iframe" data-width="1280" data-height="720" href="'.$demo_url.'"><button style="background: lightblue; padding-left: 19px; padding-right: 19px;">Przymierz</button></a>';
    }
}

Comments

Submit
0 Comments